package com.jt.resource.controller;

import com.jt.feign.RemoteProviderService;
import com.jt.system.service.DemoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 金帮嘉诚 @date 2021-08-18 星期三 21:15
 * 本类是使用feign实现远程服务方法调用
 */
@RestController
@RequestMapping("/feign/demo")
public class FeignDemoController {
    @Autowired
    private RemoteProviderService remoteProviderService;

    @GetMapping("/echo/{msg}")
    public String echo(@PathVariable("msg") String msg){
        return remoteProviderService.feignEcho(msg);
    }

    @GetMapping("/day04Echo")
    public String day04Echo(){
        return remoteProviderService.day04Echo();
    }



    @Autowired
    private DemoServiceImpl demoService;

    @GetMapping("/sentence1")
    public String getSentence1() throws InterruptedException {
        Thread.sleep(200);
        return demoService.sentence();
    }
    @GetMapping("/sentence2")
    public String getSentence2(){
        return demoService.sentence();
    }

}
